<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/views/global/taglibs.jsp"%>
<!DOCTYPE>
<html>
<head>
<base href="<%=basePath%>">

<title>Sign Up</title>
<%@include file="/views/global/include.jsp"%>
<link href="static/css/global/generic.css" rel="stylesheet"
	type="text/css">
<link href="static/css/page/loginRegister.css" rel="stylesheet"
	type="text/css">

</head>

<body>
	<div id="registerPage" class="center">
		<div class="loginHeader">
			<div class="headerArrow center"></div>
		</div>
		<div class="font en_LM textCenter registerTitle">START YOUR JOURNEY</div>
		<div class="font textCenter loginSubTitle">开启你的旅途</div>
		<form id="registerForm" name="registerForm"
			class="form-horizontal validate" method="post"
			errorPlacement="errorPlacement" role="form">
			<ul>
				<li><input id="userName" name="userName" type="text"
					class="en_M radius" placeholder="USER NAME 用户名"
					required="User name required" remote="checkUserExists"
					validateChar="true" /> <span style="display:block;height:23px;" class="error">&nbsp;</span></li>
				<li><input id="email" name="email" type="email"
					class="en_M radius" placeholder="EMAIL 邮箱"
					required="email required" /> <span style="display:block;height:23px;" class="error">&nbsp;</span></li>
				<li><input id="userPassword" name="userPassword"
					type="password" class="en_M radius" placeholder="PASSWORD 请输入密码"
					required="password required" /> <span style="display:block;height:23px;" class="error">&nbsp;</span></li>
				<li><input id="confirmPassword" name="confirmPassword"
					type="password" class="en_M radius" placeholder="CONFIRM 再次确认密码"
					required="password required" /> <span style="display:block;height:23px;" class="error">&nbsp;</span></li>
				<li>
					<div class="checkboxFour">
						<input type="checkbox" value="1" id="checkboxFourInput" name="sellerType"
							style="margin: 0; height: 10px; width: 10px;" />
							<label for="checkboxFourInput"></label>
						<p class="checkboxFour_txt">SELLER 卖家</p>
					</div>
				</li>
			</ul>
			<%-- <div class="error">${message }</div> --%>
			<input id="registerButton" name="registerButton" class="radius en_M"
				type="button" onclick="register();" value="REGISTER NOW 立即注册"> <a
				href="login"><div id="backToLogin" class="font en_SS">BACK TO LOGIN 返回登陆</div></a>
			<div id="statement" class="font en_SSS">
				BY CLICKING REGISTER, CONFIRM THAT YOU ACCEPT OUR TERMS OF USE AND 
				<a href="#"> PRIVERY POLICY </a><br>
				在注册之前，确保你已经接受网站的使用说明和<a href="#">服务条款</a>
			</div>
		</form>
	</div>
	<%@include file="/views/global/AdminScripts.jsp"%>
</body>
<script type="text/javascript">
<!--
$(document).ready(function(){
	$("#userName").focus();
});
document.errorPlacement = function(error, element){
	error.appendTo( element.parent().find(".error") );
}

document.checkUserExists = {
		type: "POST",
		url: "<%=basePath %>user/userNotExists",
		data:{userName:function(){return $("#userName").val();}},
		dataType:"json",
		msg:"User already exists."
	}

function register(){
	var seller = $("INPUT[name='sellerType']").prop("checked");
	var validator = $(registerForm).validate({meta:"validate"});
	if(validator.form()){
        $("#registerForm").goAjax({
       		type: "POST",
       		semantic: false,
       		url: 'register',
       		data:{userType: true==seller?"SELLER":"BUYER"},
       		dataType: "json",
       		error: function() {
       			$.error("网络连接发生异常");
       		},
       		success: function(jsonData) {
       			if(true == jsonData.success){
       				if("true" == '${usePanel }'){
       					if(seller==true){
       						art.dialog.data("refresh.now", "seller");
       					}else{
       						art.dialog.data("refresh.now", "true");
       					}
        				art.dialog.close();
    				} else {
    					window.location.href = "seller/store";
    				}
       			} else {
       				$.error("注册失败：" +jsonData.message);
       			}
       		}
       	});
	}
}
//-->
</script>
</html>
